home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / nfs / amd / amd-5.2 / include / am.h next >
Encoding:
C/C++ Source or Header  |  1990-06-23  |  18.2 KB  |  594 lines

  1. /*
  2.  * $Id: am.h,v 5.2 90/06/23 22:20:28 jsp Rel $
  3.  *
  4.  * Copyright (c) 1990 Jan-Simon Pendry
  5.  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  6.  * Copyright (c) 1990 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * This code is derived from software contributed to Berkeley by
  10.  * Jan-Simon Pendry at Imperial College, London.
  11.  *
  12.  * Redistribution and use in source and binary forms are permitted provided
  13.  * that: (1) source distributions retain this entire copyright notice and
  14.  * comment, and (2) distributions including binaries display the following
  15.  * acknowledgement:  ``This product includes software developed by the
  16.  * University of California, Berkeley and its contributors'' in the
  17.  * documentation or other materials provided with the distribution and in
  18.  * all advertising materials mentioning features or use of this software.
  19.  * Neither the name of the University nor the names of its contributors may
  20.  * be used to endorse or promote products derived from this software without
  21.  * specific prior written permission.
  22.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  23.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  24.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  25.  *
  26.  *    %W% (Berkeley) %G%
  27.  */
  28.  
  29. /*
  30.  * Get this in now so that OS_HDR can use it
  31.  */
  32. #ifdef __STDC__
  33. #define    P(x) x
  34. #define    P_void void
  35. #else
  36. #define P(x) ()
  37. #define P_void /* as nothing */
  38. #define const /* as nothing */
  39. #endif /* __STDC__ */
  40.  
  41. #ifdef __GNUC__
  42. #define INLINE /* __inline */
  43. #else
  44. #define    INLINE
  45. #endif /* __GNUC__ */
  46.  
  47. /*
  48.  * Pick up target dependent definitions
  49.  */
  50. #include "os-defaults.h"
  51. #include OS_HDR
  52.  
  53. #ifndef UPDATE_MTAB
  54. #define    unlock_mntlist()
  55. #endif /* UPDATE_MTAB */
  56.  
  57. #ifdef VOIDP
  58. typedef void *voidp;
  59. #else
  60. typedef char *voidp;
  61. #endif /* VOIDP */
  62.  
  63. /*
  64.  * Global declarations
  65.  */
  66. #include <stdio.h>
  67. #include <sys/param.h>
  68. #include <sys/errno.h>
  69. extern int errno;
  70. #include <sys/socket.h>
  71. #include <rpc/rpc.h>
  72. #include "nfs_prot.h"
  73. #ifdef MNTENT_HDR
  74. #include MNTENT_HDR
  75. #endif /* MNTENT_HDR */
  76. #include <sys/time.h>
  77. #include <assert.h>
  78.  
  79. #ifdef DEBUG_MEM
  80. #include <malloc.h>
  81. #endif /* DEBUG_MEM */
  82.  
  83. #ifndef MAXHOSTNAMELEN
  84. #define MAXHOSTNAMELEN 64
  85. #endif /* MAXHOSTNAMELEN */
  86.  
  87. #ifndef MNTTYPE_AUTO
  88. #define MNTTYPE_AUTO "auto"
  89. #endif /* MNTTYPE_AUTO */
  90.  
  91. #ifndef FALSE
  92. #define FALSE 0
  93. #define TRUE 1
  94. #endif /* FALSE */
  95.  
  96. #ifndef ROOT_MAP
  97. #define    ROOT_MAP "\"root\""
  98. #endif /* ROOT_MAP */
  99.  
  100. /*
  101.  * Flags from command line
  102.  */
  103. extern int print_pid;        /* Print pid to stdout */
  104. extern int normalize_hosts;    /* Normalize host names before use */
  105. extern int restart_existing_mounts;
  106. #ifdef HAS_NIS_MAPS
  107. extern char *domain;        /* NIS domain to use */
  108. #endif /* HAS_NIS_MAPS */
  109. extern FILE *logfp;        /* Log file */
  110. extern int xlog_level;        /* Logging level */
  111. #ifdef HAS_SYSLOG
  112. extern int syslogging;        /* Really using syslog */
  113. #endif /* HAS_SYSLOG */
  114. extern int am_timeo;        /* Cache period */
  115. extern int afs_timeo;        /* AFS timeout */
  116. extern int afs_retrans;        /* AFS retrans */
  117. extern int am_timeo_w;        /* Unmount timeout */
  118. extern char *mtab;        /* Mount table */
  119.  
  120. #define    XLOG_FATAL    0x0001
  121. #define    XLOG_ERROR    0x0002
  122. #define    XLOG_USER    0x0004
  123. #define    XLOG_WARNING    0x0008
  124. #define    XLOG_INFO    0x0010
  125. #define    XLOG_DEBUG    0x0020
  126. #define    XLOG_MAP    0x0040
  127. #define    XLOG_STATS    0x0080
  128.  
  129. #define XLOG_DEFSTR    "all,nomap,nostats"        /* Default log options */
  130. #define XLOG_ALL    (XLOG_FATAL|XLOG_ERROR|XLOG_USER|XLOG_WARNING|XLOG_INFO|XLOG_MAP|XLOG_STATS)
  131.  
  132. #ifdef DEBUG
  133. #ifdef DEBUG_MEM
  134. #define free(x) xfree(__FILE__,__LINE__,x)
  135. #endif /* DEBUG_MEM */
  136.  
  137. #define    DEBUG_MTAB    "./mtab"
  138.  
  139. extern int debug_flags;        /* Debug options */
  140.  
  141. #define    D_DAEMON    0x0001    /* Enter daemon mode */
  142. #define    D_TRACE        0x0002    /* Do protocol trace */
  143. #define    D_FULL        0x0004    /* Do full trace */
  144. #define    D_MTAB        0x0008    /* Use local mtab */
  145. #define    D_AMQ        0x0010    /* Register amq program */
  146. #define    D_STR        0x0020    /* Debug string munging */
  147. #define    D_MEM        0x0040    /* Trace memory allocations */
  148.  
  149. /*
  150.  * Normally, don't enter daemon mode, and don't register amq
  151.  */
  152. #define    D_TEST    (~(D_DAEMON|D_MEM|D_STR))
  153. #define    D_ALL    (~0)
  154.  
  155. #define Debug(x) if (!(debug_flags & (x))) ; else
  156. #define dlog Debug(D_FULL) dplog
  157. #endif /* DEBUG */
  158.  
  159. /*
  160.  * Option tables
  161.  */
  162. struct opt_tab {
  163.     char *opt;
  164.     int flag;
  165. };
  166.  
  167. typedef enum {
  168.     Start,
  169.     Run,
  170.     Finishing,
  171.     Quit,
  172.     Done
  173. } serv_state;
  174.  
  175. extern serv_state amd_state;    /* Should we go now */
  176. extern int immediate_abort;    /* Should close-down unmounts be retried */
  177. extern time_t do_mapc_reload;    /* Flush & reload mount map cache */
  178.  
  179. /*
  180.  * Useful constants
  181.  */
  182. extern char *progname;        /* "amd" */
  183. extern char pid_fsname[];    /* kiska.southseas.nz:(pid%d) */
  184. extern char hostname[];        /* "kiska" */
  185. extern char hostd[];        /* "kiska.southseas.nz" */
  186. extern char *hostdomain;    /* "southseas.nz" */
  187. extern char *op_sys;        /* "sos4" */
  188. extern char *arch;        /* "sun4" */
  189. extern char *karch;        /* "sun4c" */
  190. extern char *cluster;        /* "r+d-kluster" */
  191. extern char *endian;        /* "big" */
  192. extern char *auto_dir;        /* "/a" */
  193. extern char version[];        /* Version info */
  194.  
  195. typedef struct am_ops am_ops;
  196. typedef struct am_node am_node;
  197. typedef struct am_opts am_opts;
  198. typedef struct mntfs mntfs;
  199. typedef struct fserver fserver;
  200. typedef struct fsrvinfo fsrvinfo;
  201.  
  202. /*
  203.  * Global variables.
  204.  */
  205. extern unsigned short nfs_port;    /* Our NFS service port */
  206. extern int mypid;        /* Current process id */
  207. extern struct in_addr myipaddr;    /* (An) IP address of this host */
  208.  
  209. extern int foreground;        /* Foreground process */
  210. extern int orig_umask;        /* umask() on startup */
  211. #define clocktime() (clock_valid ? clock_valid : time(&clock_valid))
  212. extern time_t time P((time_t *));
  213. extern time_t clock_valid;    /* Clock needs recalculating */
  214. extern time_t next_softclock;    /* Time to call softclock() */
  215. extern int task_notify_todo;    /* Task notifier needs running */
  216. #ifdef HAS_TFS
  217. extern int nfs_server_code_available;
  218. #endif /* HAS_TFS */
  219. extern int last_used_map;    /* Last map being used for mounts */
  220. extern AUTH *nfs_auth;        /* Dummy uthorisation for remote servers */
  221. extern am_node *exported_ap[];    /* List of nodes */
  222. extern int first_free_map;    /* First free node */
  223. #define    NEXP_AP    (256)
  224.  
  225. typedef int (*task_fun)P((voidp));
  226. typedef void (*cb_fun)P((int, int, voidp));
  227. typedef void (*fwd_fun)P((voidp, int, struct sockaddr_in *,
  228.                 struct sockaddr_in *, voidp, int));
  229.  
  230. /*
  231.  * String comparison macros
  232.  */
  233. #define STREQ(s1, s2) (strcmp((s1), (s2)) == 0)
  234. #define FSTREQ(s1, s2) ((*(s1) == *(s2)) && STREQ((s1),(s2)))
  235.  
  236. /*
  237.  * Linked list
  238.  */
  239. typedef struct qelem qelem;
  240. struct qelem {
  241.     qelem *q_forw;
  242.     qelem *q_back;
  243. };
  244. #define    FIRST(ty, q)    ((ty *) ((q)->q_forw))
  245. #define    LAST(ty, q)    ((ty *) ((q)->q_back))
  246. #define    NEXT(ty, q)    ((ty *) (((qelem *) q)->q_forw))
  247. #define    PREV(ty, q)    ((ty *) (((qelem *) q)->q_back))
  248. #define    HEAD(ty, q)    ((ty *) q)
  249. #define    ITER(v, ty, q) \
  250.     for ((v) = FIRST(ty,(q)); (v) != HEAD(ty,(q)); (v) = NEXT(ty,(v)))
  251.  
  252. /*
  253.  * List of mount table entries
  254.  */
  255. typedef struct mntlist mntlist;
  256. struct mntlist {
  257.     struct mntlist *mnext;
  258.     struct mntent *mnt;
  259. };
  260.  
  261. /*
  262.  * Mount map
  263.  */
  264. typedef struct mnt_map mnt_map;
  265.  
  266. /*
  267.  * Global routines
  268.  */
  269. extern int atoi P((const char *)); /* C */
  270. extern void am_mounted P((am_node*));
  271. extern void am_unmounted P((am_node*));
  272. extern int background(P_void);
  273. extern int bind_resv_port P((int, unsigned short*));
  274. extern int compute_mount_flags P((struct mntent *));
  275. extern int softclock(P_void);
  276. #ifdef DEBUG
  277. extern int debug_option P((char*));
  278. extern void dplog ();
  279. /*extern void dplog P((char*, ...));*/
  280. #endif /* DEBUG */
  281. /*extern void domain_strip P((char*, char*));*/
  282. extern mntfs* dup_mntfs P((mntfs*));
  283. extern fserver* dup_srvr P((fserver*));
  284. extern int eval_fs_opts P((am_opts*, char*, char*, char*, char*, char*));
  285. extern char* expand_key P((char*));
  286. extern am_node* exported_ap_alloc(P_void);
  287. extern am_node* find_ap P((char*));
  288. extern mntfs* find_mntfs P((am_ops*, am_opts*, char*, char*, char*));
  289. extern void flush_mntfs(P_void);
  290. extern FREE_RETURN_TYPE free P((voidp)); /* C */
  291. extern void free_mntfs P((mntfs*));
  292. extern void free_opts P((am_opts*));
  293. extern void free_map P((am_node*));
  294. extern void free_mntlist P((mntlist*));
  295. extern int fwd_init(P_void);
  296. extern int fwd_packet P((int, voidp, int, struct sockaddr_in *,
  297.         struct sockaddr_in *, voidp, fwd_fun));
  298. extern void fwd_reply(P_void);
  299. extern void get_args P((int, char*[]));
  300. extern void going_down P((int));
  301. #ifdef NEED_MNTOPT_PARSER
  302. extern char *hasmntopt P((struct mntent*, char*));
  303. #endif /* NEED_MNTOPT_PARSER */
  304. extern int hasmntval P((struct mntent*, char*));
  305. extern void host_normalize P((char **));
  306. extern void init_map P((am_node*, char*));
  307. extern void insert_am P((am_node*, am_node*));
  308. extern void ins_que P((qelem*, qelem*));
  309. extern void make_root_node(P_void);
  310. extern int make_rpc_packet P((char*, int, u_long, struct rpc_msg*, voidp, xdrproc_t, AUTH*));
  311. extern void mapc_add_kv P((mnt_map*, char*, char*));
  312. extern mnt_map* mapc_find P((char*, char*));
  313. extern void mapc_free P((mnt_map*));
  314. extern int mapc_search P((mnt_map*, char*, char**));
  315. extern void mapc_reload(P_void);
  316. extern void mapc_showtypes P((FILE*));
  317. extern int mkdirs P((char*, int));
  318. extern void mnt_free P((struct mntent*));
  319. extern int mount_automounter P((int));
  320. extern int mount_exported(P_void);
  321. extern int mount_node P((am_node*));
  322. extern mntfs* new_mntfs(P_void);
  323. extern void new_ttl P((am_node*));
  324. extern am_node* next_map P((int*));
  325. extern int nfs_srvr_port P((fserver*, u_short*, voidp));
  326. extern int pickup_rpc_reply P((voidp, int, voidp, xdrproc_t));
  327. extern void plog ();
  328. /*extern void plog P((int, char*, ...));*/
  329. extern mntlist* read_mtab P((char*));
  330. extern mntfs* realloc_mntfs  P((mntfs*, am_ops*, am_opts*, char*, char*, char*));
  331. extern void rem_que P((qelem*));
  332. extern void reschedule_timeout_mp(P_void);
  333. extern void restart(P_void);
  334. #ifdef UPDATE_MTAB
  335. extern void rewrite_mtab P((mntlist *));
  336. #endif /* UPDATE_MTAB */
  337. extern void rmdirs P((char*));
  338. extern am_node* root_ap P((char*, int));
  339. extern void root_newmap P((char*, char*, char*));
  340. extern void rpc_msg_init P((struct rpc_msg*, u_long, u_long, u_long));
  341. extern void run_task P((task_fun, voidp, cb_fun, voidp));
  342. extern void sched_task P((cb_fun, voidp, voidp));
  343. extern void show_rcs_info P((const char*, char*));
  344. extern void sigchld P((int));
  345. extern void srvrlog P((fserver*, char*));
  346. extern char* str3cat P((char*, char*, char*, char*));
  347. extern char* strcat P((char*, const char*)); /* C */
  348. extern char* strchr P((const char*, int)); /* C */
  349. extern int strcmp P((const char*, const char*)); /* C */
  350. extern char* strdup P((const char*));
  351. extern int strlen P((const char*)); /* C */
  352. extern char* strnsave P((const char*, int));
  353. extern char* strrchr P((const char*, int)); /* C */
  354. extern char* strealloc P((char*, char *));
  355. extern char** strsplit P((char*, int));
  356. extern int switch_option P((char*));
  357. extern void task_notify(P_void);
  358. extern int timeout P((unsigned int, void (*fn)(), voidp));
  359. extern void timeout_mp(P_void);
  360. extern void umount_exported(P_void);
  361. /*extern int unmount_node P((am_node*));
  362. extern int unmount_node_wrap P((voidp));*/
  363. extern void unregister_amq(P_void);
  364. extern void untimeout P((int));
  365. extern int valid_key P((char*));
  366. extern void wakeup P((voidp));
  367. extern void wakeup_task P((int,int,voidp));
  368. extern void wakeup_srvr P((fserver*));
  369. extern void write_mntent P((struct mntent*));
  370. extern voidp xmalloc P((int));
  371. extern voidp xrealloc P((voidp, int));
  372.  
  373. #define    ALLOC(ty)    ((struct ty *) xmalloc(sizeof(struct ty)))
  374.  
  375. /*
  376.  * Options
  377.  */
  378. struct am_opts {
  379.     char    *fs_glob;        /* Smashed copy of global options */
  380.     char    *fs_local;        /* Expanded copy of local options */
  381.     char    *fs_mtab;        /* Mount table entry */
  382.     /* Other options ... */
  383.     char    *opt_dev;
  384.     char    *opt_delay;
  385.     char    *opt_dir;
  386.     char    *opt_fs;
  387.     char    *opt_group;
  388.     char    *opt_mount;
  389.     char    *opt_opts;
  390.     char    *opt_pref;
  391.     char    *opt_cache;
  392.     char    *opt_rfs;
  393.     char    *opt_rhost;
  394.     char    *opt_sublink;
  395.     char    *opt_type;
  396.     char    *opt_unmount;
  397.     char    *opt_user;
  398. };
  399.  
  400. /*
  401.  * File Handle
  402.  *
  403.  * This is interpreted by indexing the exported array
  404.  * by fhh_id.
  405.  *
  406.  * The whole structure is mapped onto a standard fhandle_t
  407.  * when transmitted.
  408.  */
  409. struct am_fh {
  410.     int    fhh_pid;        /* process id */
  411.     int    fhh_id;            /* map id */
  412.     int    fhh_gen;        /* generation number */
  413. };
  414.  
  415. extern am_node *fh_to_mp P((nfs_fh*));
  416. extern am_node *fh_to_mp3 P((nfs_fh*,int*,int));
  417. extern void mp_to_fh P((am_node*, nfs_fh*));
  418. #define    fh_to_mp2(fhp, rp) fh_to_mp3(fhp, rp, VLOOK_CREATE)
  419.  
  420. typedef int    (*vfs_match)P((am_opts*));
  421. typedef int    (*vfs_init)P((mntfs*));
  422. typedef int    (*vmount_fs)P((am_node*));
  423. typedef int    (*vumount_fs)P((am_node*));
  424. typedef am_node*(*vlookuppn)P((am_node*, char*, int*, int));
  425. typedef int    (*vreaddir)P((am_node*, nfscookie, dirlist*, entry*));
  426. typedef am_node*(*vreadlink)P((am_node*, int*));
  427. typedef int    (*vmounted)P((mntfs*));
  428. typedef void    (*vumounted)P((am_node*));
  429. typedef fserver*(*vffserver)P((mntfs*));
  430.  
  431. struct am_ops {
  432.     char        *fs_type;
  433.     vfs_match    fs_match;
  434.     vfs_init    fs_init;
  435.     vmount_fs    mount_fs;
  436.     vumount_fs    umount_fs;
  437.     vlookuppn    lookuppn;
  438.     vreaddir    readdir;
  439.     vreadlink    readlink;
  440.     vmounted    mounted;
  441.     vumounted    umounted;
  442.     vffserver    ffserver;
  443.     int        fs_flags;
  444. };
  445. extern am_node *efs_lookuppn P((am_node*, char*, int*, int));
  446. extern int efs_readdir P((am_node*, nfscookie, dirlist*, entry*));
  447.  
  448. #define    VLOOK_CREATE    0x1
  449. #define    VLOOK_DELETE    0x2
  450.  
  451. #define    FS_RETRY    0x0001        /* Retry this type of mount */
  452. #define    FS_MBACKGROUND    0x0002        /* Should background this mount */
  453. #define    FS_NOTIMEOUT    0x0004        /* Don't bother with timeouts */
  454. #define FS_MKMNT    0x0008        /* Need to make the mkdir point */
  455. #define FS_UBACKGROUND    0x0010        /* Unmount in background */
  456. #define    FS_BACKGROUND    (FS_MBACKGROUND|FS_UBACKGROUND)
  457. #define    FS_DISCARD    0x0020        /* Discard immediately on last reference */
  458. #define    FS_AMQINFO    0x0040        /* Amq is interested in this fs type */
  459.  
  460. #ifdef SUNOS4_COMPAT
  461. extern am_ops *sunos4_match P((am_opts*, char*, char*, char*, char*, char*));
  462. #endif /* SUNOS4_COMPAT */
  463. extern am_ops *ops_match P((am_opts*, char*, char*, char*, char*, char*));
  464. #include "fstype.h"
  465.  
  466. /*
  467.  * Per-mountpoint statistics
  468.  */
  469. struct am_stats {
  470.     time_t    s_mtime;    /* Mount time */
  471.     u_short    s_uid;        /* Uid of mounter */
  472.     int    s_getattr;    /* Count of getattrs */
  473.     int    s_lookup;    /* Count of lookups */
  474.     int    s_readdir;    /* Count of readdirs */
  475.     int    s_readlink;    /* Count of readlinks */
  476.     int    s_statfs;    /* Count of statfs */
  477. };
  478. typedef struct am_stats am_stats;
  479.  
  480. /*
  481.  * System statistics
  482.  */
  483. struct amd_stats {
  484.     int    d_drops;    /* Dropped requests */
  485.     int    d_stale;    /* Stale NFS handles */
  486.     int    d_mok;        /* Succesful mounts */
  487.     int    d_merr;        /* Failed mounts */
  488.     int    d_uerr;        /* Failed unmounts */
  489. };
  490. extern struct amd_stats amd_stats;
  491.  
  492. /*
  493.  * List of fileservers
  494.  */
  495. struct fserver {
  496.     qelem        fs_q;        /* List of fileservers */
  497.     int        fs_refc;    /* Number of references to this node */
  498.     char        *fs_host;    /* Normalized hostname of server */
  499.     struct sockaddr_in *fs_ip;    /* Network address of server */
  500.     int        fs_cid;        /* Callout id */
  501.     int        fs_pinger;    /* Ping (keepalive) interval */
  502.     int        fs_flags;    /* Flags */
  503.     char        *fs_type;    /* File server type */
  504.     voidp        fs_private;    /* Private data */
  505.     void        (*fs_prfree)();    /* Free private data */
  506. };
  507. #define    FSF_VALID    0x0001        /* Valid information available */
  508. #define    FSF_DOWN    0x0002        /* This fileserver is thought to be down */
  509. #define    FSF_ERROR    0x0004        /* Permanent error has occured */
  510. #define    FSF_WANT    0x0008        /* Want a wakeup call */
  511. #define    FSF_PINGING    0x0010        /* Already doing pings */
  512. #define    FSRV_ISDOWN(fs)    (((fs)->fs_flags & (FSF_DOWN|FSF_VALID)) == (FSF_DOWN|FSF_VALID))
  513. #define    FSRV_ISUP(fs)    (((fs)->fs_flags & (FSF_DOWN|FSF_VALID)) == (FSF_VALID))
  514.  
  515. /*
  516.  * List of mounted filesystems
  517.  */
  518. struct mntfs {
  519.     qelem        mf_q;        /* List of mounted filesystems */
  520.     am_ops        *mf_ops;    /* Operations on this mountpoint */
  521.     am_opts        *mf_fo;        /* File opts */
  522.     struct attrstat    mf_attr;    /* File attributes */
  523. #define mf_fattr    mf_attr.attrstat_u.attributes
  524.     char        *mf_mount;    /* "/a/kiska/home/kiska" */
  525.     char        *mf_info;    /* Mount info */
  526.     char        *mf_opts;    /* Mount opts */
  527.     fserver        *mf_server;    /* File server */
  528.     int        mf_flags;    /* Flags */
  529.     int        mf_error;    /* Error code from background mount */
  530.     int        mf_refc;    /* Number of references to this node */
  531.     int        mf_cid;        /* Callout id */
  532.     void        (*mf_prfree)();    /* Free private space */
  533.     voidp        mf_private;    /* Private - per-fs data */
  534. };
  535.  
  536. #define    MFF_MOUNTED    0x0001        /* Node is mounted */
  537. #define    MFF_MOUNTING    0x0002        /* Mount is in progress */
  538. #define    MFF_UNMOUNTING    0x0004        /* Unmount is in progress */
  539. #define    MFF_RESTART    0x0008        /* Restarted node */
  540. #define MFF_MKMNT    0x0010        /* Delete this node's am_mount */
  541. #define    MFF_ERROR    0x0020        /* This node failed to mount */
  542. #define    MFF_LOGDOWN    0x0040        /* Logged that this mount is down */
  543. #define    MFF_RSTKEEP    0x0080        /* Don't timeout this filesystem - restarted */
  544. #define    MFF_WANTTIMO    0x0100        /* Need a timeout call when not busy */
  545.  
  546. /*
  547.  * Map of auto-mount points.
  548.  */
  549. struct am_node {
  550.     int        am_mapno;    /* Map number */
  551.     mntfs        *am_mnt;    /* Mounted filesystem */
  552.     char        *am_name;    /* "kiska"
  553.                        Name of this node */
  554.     char        *am_path;    /* "/home/kiska"
  555.                        Path of this node's mount point */
  556.     char        *am_link;    /* "/a/kiska/home/kiska/this/that"
  557.                        Link to sub-directory */
  558.     am_node        *am_parent,    /* Parent of this node */
  559.             *am_ysib,    /* Younger sibling of this node */
  560.             *am_osib,    /* Older sibling of this node */
  561.             *am_child;    /* First child of this node */
  562.     int        am_flags;    /* Boolean flags */
  563.     int        am_error;    /* Specific mount error */
  564.     time_t        am_ttl;        /* Time to live */
  565.     int        am_timeo_w;    /* Wait interval */
  566.     int        am_timeo;    /* Timeout interval */
  567.     unsigned int    am_gen;        /* Generation number */
  568.     char        *am_pref;    /* Mount info prefix */
  569.     am_stats    am_stats;    /* Statistics gathering */
  570. };
  571.  
  572. #define    AMF_NOTIMEOUT    0x0001        /* This node never times out */
  573. #define    AMF_ROOT    0x0002        /* This is a root node */
  574. #define AMF_MKPATH    0x0004        /* Delete this node's am_path */
  575.  
  576. #define    ONE_HOUR    (60 * 60)    /* One hour in seconds */
  577.  
  578. /*
  579.  * The following values can be tuned...
  580.  */
  581. #define    ALLOWED_MOUNT_TIME    40        /* 40s for a mount */
  582. #define    AM_TTL            (5 * 60)    /* Default cache period */
  583. #define    AM_TTL_W        (2 * 60)    /* Default unmount interval */
  584. #define    AM_PINGER        30        /* NFS ping interval for live systems */
  585. #define    AFS_TIMEO        8        /* Default afs timeout - .8s */
  586. #define    AFS_RETRANS        ((ALLOWED_MOUNT_TIME*10+2*afs_timeo)/afs_timeo)
  587.                         /* Default afs timeout - 1/10th seconds */
  588.  
  589. #define    RPC_XID_PORTMAP        0
  590. #define    RPC_XID_MOUNTD        1
  591. #define    RPC_XID_NFSPING        2
  592. #define    RPC_XID_MASK        (0x0f)        /* 16 id's for now */
  593. #define    MK_RPC_XID(type_id, uniq)    ((type_id) | ((uniq) << 4))
  594.